{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Everthing is Ok now, thanks [Samy Pessé](http://www.samypesse.fr/).\n",
    "\n",
    "Lastest version at [The Swift Programming Language 中文版][5].\n",
    "\n",
    "~~由于[The Swift Programming Language 中文版][5]不能swift语言高亮.~~\n",
    "\n",
    "Enjoy：\n",
    "\n",
    "- [Swift Codeblocks Syntax Highlight](http://swift.coding.io/) on [Coding][0].\n",
    "\n",
    "- [Swift Codeblocks Syntax Highlight](http://muxuezi.gitbooks.io/swift-codeblocks/) on [Gitbhub][4].\n",
    "\n",
    "<!-- TEASER_END-->\n",
    "\n",
    "~~There's a swfit syntax bug highlight on[Gitbook][2]now, even though [Samy Pessé](http://www.samypesse.fr/) had upgraded the highlight version of [gitbook/package.json](https://github.com/GitbookIO/gitbook) to [8.1.0](https://highlightjs.org/), which support swfit syntax.~~\n",
    "\n",
    "- [Coding][1]和[Gitbook][2]都通过[highlightjs][3]支持swift语法高亮;\n",
    "- [Coding][0]和[Github][4]可以在代码管理页面直接语法高亮;\n",
    "- [Gitbook][2]还不行，如[首页](https://www.gitbook.io/book/muxuezi/swift-codeblocks)不支持swift语法高亮。\n",
    "\n",
    "如果不论PDF、MOBI、EPUB格式输出，则\n",
    "$$Coding \\approx Github + Gitbook$$\n",
    "\n",
    "一般html解决办法见[highlightjs][3]，需要xcode.css、highlight.pack.js，并在head增加:\n",
    "\n",
    "```html\n",
    "<link rel=\"stylesheet\" href=\"../assets/css/xcode.css\">\n",
    "<script src=\"../assets/js/highlight.pack.js\"></script>\n",
    "<script>hljs.initHighlightingOnLoad();</script>\n",
    "```\n",
    "[0]:https://coding.net/u/tj2/p/swift/git\n",
    "[1]:https://coding.net/ \"Coding\"\n",
    "[2]:https://www.gitbook.io \"Gitbook\"\n",
    "[3]:https://highlightjs.org/usage/ \"highlightjs\"\n",
    "[4]:https://github.com/muxuezi/swift-codeblocks/\n",
    "[5]:http://numbbbbb.gitbooks.io/-the-swift-programming-language-/"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<link rel=\"stylesheet\" href=\"../assets/css/xcode.css\">\n",
    "<script src=\"../assets/js/highlight.pack.js\"></script>\n",
    "<script>hljs.initHighlightingOnLoad();</script>\n",
    "\n",
    "Test:\n",
    "\n",
    "```swift\n",
    "extension OCBool: Equatable{\n",
    "}\n",
    "\n",
    "//支持等值判断运算符\n",
    "func ==( left: OCBool, right: OCBool )->Bool{\n",
    "    switch (left, right){\n",
    "    case (.ocTrue, .ocTrue):\n",
    "            return true\n",
    "    default:\n",
    "        return false\n",
    "    }\n",
    "}\n",
    "//支持位与运算符\n",
    "func &( left:OCBool, right: OCBool)->OCBool{\n",
    "\n",
    "    if left{\n",
    "        return right\n",
    "    }\n",
    "    else{\n",
    "        return false\n",
    "    }\n",
    "}\n",
    "//支持位或运算符\n",
    "func |( left:OCBool, right: OCBool)->OCBool{\n",
    "\n",
    "    if left{\n",
    "        return true\n",
    "    }\n",
    "    else{\n",
    "        return right\n",
    "    }\n",
    "}\n",
    "\n",
    "//支持位异或运算符\n",
    "func ^( left:OCBool, right: OCBool)->OCBool{\n",
    "    return OCBool( left != right )\n",
    "}\n",
    "//支持求反运算符\n",
    "@prefix func !( a:OCBool )-> OCBool{\n",
    "    return a ^ true\n",
    "}\n",
    "//支持组合求与运算符\n",
    "func &= (inout left:OCBool, right:OCBool ){\n",
    "    left = left & right\n",
    "}\n",
    "\n",
    "\n",
    "var isHasMoney:OCBool = true\n",
    "var isHasWife:OCBool = true\n",
    "var isHasHealty:OCBool = true\n",
    "var isHasLover:OCBool = true\n",
    "\n",
    "isHasMoney != isHasHealty\n",
    "isHasHealty == isHasMoney\n",
    "isHasWife ^ isHasLover\n",
    "isHasWife = !isHasLover\n",
    "\n",
    "if (isHasMoney | isHasHealty) & isHasHealty{\n",
    "    println( \"坐看云起时\")\n",
    "}else\n",
    "{\n",
    "    println(\"千金散尽还复来\")\n",
    "}\n",
    "```\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "[![Build Status](https://www.gitbook.io/button/status/book/muxuezi/swift-codeblocks)](https://www.gitbook.io/book/muxuezi/swift-codeblocks/activity)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
